//滚动
export function scrollY(height,ul,time){
	ul.append('<li>'+ul.find('li').eq(0).html()+'</li>')
	height=height.height()
	var num=0
	setInterval(function(){
		num++;
		if(num===ul.find('li').length){
			num=1
			ul.css({
				marginTop:0
			})
		}		
		ul.animate({
			marginTop:-height*num
		},400)
	},time)
}

//微信分享
export function weshare(url) {
	$.ajax({
	  type: "GET",
	  url:
		"http://120.221.153.170:8090/wechatflowfruit/commonCtl/getSignature?url=" +
		encodeURIComponent(url),
	  dataType: "json",
	  async: false,
	  success: function(data) {
		let Signature =  JSON.parse(data.data);
		wx.config({
		  debug: false,
		  appId: "wx43a850f87498127d",
		  timestamp: Signature.timeStamp,
		  nonceStr: Signature.nonceStr,
		  signature: Signature.jsSignature,
		  jsApiList: [
			"onMenuShareTimeline",
			"onMenuShareAppMessage",
			"onMenuShareQQ",
			"onMenuShareQZone"
		  ]
		});
		wx.ready(function() {
		  wx.onMenuShareTimeline({
			title: "@你，有份话费大礼待领取！", // 分享标题
			link: url, // 分享链接
			imgUrl:
			  "http://wx.10086.cn/shandong/wx/otherSamllProject/shareIcon/wx_sign.png",
			success: function() {
			},
			cancel: function() {
			  // 用户取消分享后执行的回调函数
			}
		  });
  
		  wx.onMenuShareAppMessage({
			title: "赚话费竟然这么容易？！", // 分享标题
			desc:
			  "签到来就对，天天领话费", // 分享描述
			link: url,
			imgUrl:
			  "http://wx.10086.cn/shandong/wx/otherSamllProject/shareIcon/wx_sign.png",
			success: function() {
			},
			cancel: function() {
			  // 用户取消分享后执行的回调函数
			}
		  });
		});
	  }
	});
	}
	
	export function  GetQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]);
		return null;
	}
	
	export function format(time, format) {
    var t = new Date(time);
    var tf = function(i) {
      return(i < 10 ? '0' : '') + i
    };
    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a) {
      switch(a) {
        case 'yyyy':
          return tf(t.getFullYear());
          break;
        case 'MM':
          return tf(t.getMonth() + 1);
          break;
        case 'mm':
          return tf(t.getMinutes());
          break;
        case 'dd':
          return tf(t.getDate());
          break;
        case 'HH':
          return tf(t.getHours());
          break;
        case 'ss':
          return tf(t.getSeconds());
          break;
      }
    })
	}
	
	export function safeStr(str){
    return str.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  }